package 树;

import java.util.ArrayList;
import java.util.List;

public class Demo12 {
    /*
     * dfs 爆杀
     * */
    static class Solution2 {
        private List<Integer> list = new ArrayList<>();
        public List<Integer> rightSideView(TreeNode root) {
            dfs(root,0);
            return list;
        }

        public void dfs(TreeNode root,int high){
            if(root == null){
                return;
            }
            if(high == list.size()){
                list.add(root.val);
            }
            dfs(root.right,high+1);
            dfs(root.left,high+1);
        }
    }



}
